FROM node:16.17

WORKDIR /wave_service_web/
COPY . .

ARG IP_ADDRESS

RUN sed -i "/VITE_CUSTCARE_SERVER = http:\/\/127.0.0.1:8182/cVITE_CUSTCARE_SERVER = http:\/\/$IP_ADDRESS:8182" .env.production
RUN sed -i "/VITE_CUSTCARE_WS_SERVER = ws:\/\/127.0.0.1:9182/cVITE_CUSTCARE_WS_SERVER = ws:\/\/$IP_ADDRESS:9182" .env.production

RUN npm config set registry https://registry.npm.taobao.org --global

RUN npm -v

RUN node -v

RUN npm install && npm run build

FROM nginx:latest
LABEL maintainer="xuping <361131953@qq.com>"

COPY .docker-compose/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf
COPY --from=0 /wave_service_web/dist /usr/share/nginx/html
COPY --from=0 /wave_service_web/images /usr/share/nginx/html/images
COPY open_chat.html /usr/share/nginx/html/open_chat.html
COPY open_chat.js /usr/share/nginx/html/open_chat.js
COPY logo.png /usr/share/nginx/html/logo.png

RUN cat /etc/nginx/nginx.conf
RUN cat /etc/nginx/conf.d/default.conf
RUN cat /usr/share/nginx/html/open_chat.html
RUN ls -al /usr/share/nginx/html